const data= require('../../../../lib/data')
const result = require('../../../../lib/result')
class open {
   static async send(ctx) {
   
   // console.log(ctx.params);
    const command = Buffer.from([ 0xA0, 0x01]);
    
    if(!ctx.query.area ||!ctx.query.column){
        result.time =  (new Date()).getTime();
        result.succeed = false;
        return result 
    }
    console.log(ctx.query);
    const raw = Buffer.from([ctx.query.area, ctx.query.column]);
    ctx.state.socket.write(data.pack(command, raw));
    result.time =  (new Date()).getTime();
    result.succeed = true;
    return result
  }
}

module.exports = open